function [dptr] = wildload(filenames)
% WILDLOAD.M
%
% Use wildcards to load DOS data files -- prompts for path and file descriptor string
%   Prompted input string example: c:\data\ab??rd.*
%
%   Structure array "WILDCARDd" is left in the workspace to be used in 
%   addressing the data which was loaded 
%   (WILDCARDd(i).name returns the variable name for the ith-loaded file)
%
% Don Clare - clare@us.ibm.com
% modified P. Manis 12/21/98 to use passed argument; data is then returned in structure
% if there is any
WILDCARd=[];
WILDCARDp=[];
%Prompt user for string
WILDCARDs = filenames;
%Generate a structure array for all files meeting the user inputted criteria
WILDCARDd=dir(WILDCARDs);
WILDCARDfdelim=find(WILDCARDs == '\');
%Separate the path from the user inputted string
if size(WILDCARDfdelim > 0),
   WILDCARDp=WILDCARDs(1:WILDCARDfdelim(max(size(WILDCARDfdelim))));
end
%Load the files using the path information and the structure array generated from dir
clear WILDCARDp WILDCARDi WILDCARDs WILDCARDfdelim 
dptr = WILDCARDd;
return
for WILDCARDi=1:max(size(WILDCARDd)), % do this in your own program to get the data where it belongs.
   load([WILDCARDp WILDCARDd(WILDCARDi).name])
end
%Clean up (Leave WILDCARDd, which can be used to address the loaded data)
clear WILDCARDp WILDCARDi WILDCARDs WILDCARDfdelim 
return
